import { _decorator, color, Color, Component, instantiate, Label, Node, Prefab, tween, UIOpacity, UITransform, v3, Widget, Layout } from 'cc';

const { ccclass, property } = _decorator;

@ccclass('rewardBox')
export class rewardBox extends Component {

    cor: Color = color().fromHEX('#3BFF43');

    private _list: Array<any>;
    public get list(): Array<any> {
        return this._list;
    }
    public set list(v: Array<any>) {
        this._list = v;
    }

    @property(Prefab)
    reward: Prefab;

    start() {
        this.upList();
    }

    /**更新列表 */
    upList() {
        this.node.removeAllChildren()
        this.list.forEach((name) => {
            let item = instantiate(this.reward)
            this.node.addChild(item)
            item.getChildByName("rewardItem").getComponent(Label).color = this.cor;
            item.getChildByName("rewardItem").getComponent(Label).string = name;
        })
        this.node.getComponent(Widget).enabled = false
        tween(this.node)
            .to(1.2, {
                position: v3(0, 200, 0)
            }, { easing: "backIn" }
            ).call(() => {
                console.log("55555");

                this.node.destroy();
            })

            .start();
        
    }


}


